//
//  SDHSportsPlayInfoDetailView.m
//  SDHSportsNews
//
//  Created by MichaelShan on 2021/3/12.
//

#import "SDHSportsPlayInfoDetailView.h"

#define PlayInfoDetailTextColor UIColorFromRGB(140, 140, 140)


@interface SDHSportsPlayInfoDetailView ()

@property (nonatomic, strong) UILabel *detailLb;
@property (nonatomic, strong) UILabel *titleLb;

@end

@implementation SDHSportsPlayInfoDetailView

- (id)init {
    if (self = [super init]) {
        [self initUI];
    }
    
    return self;
}

- (void)initUI {
    UILabel *detailLb = [UILabel new];
    self.backgroundColor = [UIColor greenColor];
    detailLb.textColor = PlayInfoDetailTextColor;
    detailLb.textAlignment = NSTextAlignmentCenter;
    detailLb.font = [UIFont systemFontOfSize:16];
    detailLb.numberOfLines = 0;
    [self addSubview:detailLb];
    self.detailLb = detailLb;
    detailLb.text = @"Panelty kick unload the ball";
    
    UILabel *separatorLb = [UILabel new];
    separatorLb.backgroundColor = [UIColor whiteColor];
    [self addSubview:separatorLb];
    
    UILabel *titleLb = [UILabel new];
    titleLb.textColor = PlayInfoDetailTextColor;
    titleLb.textAlignment = NSTextAlignmentCenter;
    titleLb.font = [UIFont systemFontOfSize:16];
    [self addSubview:titleLb];
    titleLb.text = @"Style";
    self.titleLb = titleLb;
    
    [detailLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(separatorLb.mas_top).offset(-5);
        make.left.mas_equalTo(5);
        make.right.mas_equalTo(5);
    }];
    
    [separatorLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self);
        make.bottom.equalTo(titleLb.mas_top).offset(-5);
        make.width.mas_equalTo(80);
        make.height.mas_equalTo(2);
    }];
    
    [titleLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self).offset(70);
        make.left.mas_equalTo(5);
        make.right.mas_equalTo(5);
    }];
}

- (void)setTitle:(NSString *)title {
    if (title == nil) {
        _titleLb.hidden = YES;
    } else if (title.length == 0) {
        _titleLb.hidden = YES;
    } else {
        _titleLb.hidden = NO;
        _titleLb.text = title;
    }
}

- (void)setDetail:(NSString *)detail {
    if (detail.length == 0) {
        _detailLb.text = @"-";
    } else {
        _detailLb.text = detail;
    }
}

@end
